package com.csu.service.impl;

import com.csu.dao.BookDao;
import com.csu.dao.impl.BookDaoImpl;
import com.csu.entiry.Book;
import com.csu.service.BookService;

import java.util.List;

public class BookServiceImpl implements BookService {

    private final BookDao bookDao = new BookDaoImpl();


    @Override
    public List<Book> getBookList(int current, int size, String key) {
        return bookDao.getBookList(current, size, key);
    }

    @Override
    public int getTotal(int current, int size, String key) {
        return bookDao.getTotal(current, size, key);
    }

    @Override
    public void addBook(Book book) {
        bookDao.insertBook(book);
    }

    @Override
    public void removeBook(int id) {
        bookDao.deleteBook(id);
    }

    @Override
    public void updateBook(Book book) {
        bookDao.updateBook(book);
    }

    @Override
    public Book getById(int id) {
        return bookDao.getBookById(id);
    }

    @Override
    public int getIdByName(String bookname) {
        return bookDao.getIdByName(bookname);
    }

    @Override
    public List<String> searchName(String key) {
        return bookDao.searchName(key);
    }

    @Override
    public List<Book> getAllBookList(String key) {
        return bookDao.getBookListByUpSort(key);
    }

    @Override
    public List<Book> getAllBookListByDesc(String key) {
        return bookDao.getBookListByDownSort(key);
    }
}
